# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=tifffile
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2020.9.22
pkgrel=1
pkgdesc='Read and write image data from and to TIFF files (mingw-w64)'
arch=('any')
url="https://github.com/cgohlke/tifffile"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python-numpy")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-matplotlib: required only for plotting")
source=("https://files.pythonhosted.org/packages/source/${_realname:0:1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('505a0ddf372697e8dacd3a8bc486f7143df44772b0fd72ca56486b6b46cbe494')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
